Hello,
int LinesCntOfBuffer1 = 0
int LinesCntOfBuffer2 = 0
Skip LinesOfBuffer1 = create ()
Skip LinesOfBuffer2 = create ()
Buffer firstrun = create (0); firstrun = "Some large Buffer1\nSome large Buffer2\nExtra Line\n"
Buffer secondrun = create (0); secondrun = "Some large Buffer3\nSome large Buffer4\n"
void parseBufferLine(Buffer &source, Skip &SkpList, int &lineCnt) {
Regexp line = regexp2 ".*" // matches up to newline
int from = 0
lineCnt = 0 // Zero out
string match = null
setempty(SkpList)
while (search(line, source, from)) {
// takes a line at a time from source
int offset = end 0
// end of the match within source
match = plainText source[from:from+offset]
// move 'from' over any newline
if (null match) { break } // we are done
put(SkpList, lineCnt++, match)
from += offset + 2
match = null
}
delete line
delete source
}
void diffx(Skip &Buffer1, Skip &Buffer2)
{
Buffer buff1 = create(); setempty(buff1)
Buffer buff2 = create(); setempty(buff2)
Buffer resBuf = create(); setempty(resBuf)
Buffer tempBuffer = create(); setempty(tempBuffer)
string str = null
string temp = null
//Make buffers have the same line count.
int newlines = 0
int i = 0
if(LinesCntOfBuffer1 < LinesCntOfBuffer2) {
newlines = LinesCntOfBuffer2 - LinesCntOfBuffer1
for(i = LinesCntOfBuffer2; i < (LinesCntOfBuffer2+newlines); i++) {
put(Buffer1, LinesCntOfBuffer1++, "")
}
} else if(LinesCntOfBuffer1 > LinesCntOfBuffer2) {
newlines = LinesCntOfBuffer1 - LinesCntOfBuffer2
for(i = LinesCntOfBuffer1; i < (LinesCntOfBuffer1+newlines); i++) {
put(Buffer2, LinesCntOfBuffer2++, "")
}
} else {
}
for str in Buffer1 do
{
setempty(buff1); setempty(buff2)
int index = key(Buffer1)
if(find(Buffer2, index, temp))
{
buff1 = str; buff2 = temp
diff(resBuf, buff1, buff2, true)
combine(tempBuffer, resBuf, 0)
buff2 = "\\par "
combine(tempBuffer, resBuf, 0)
/*output
buff2 = "\\par "
combine(tempBuffer, resBuf, 0)
buff2 = "\\par "
----------------------------------------------------------------
Some large Buffer1Buffer3
Some large Buffer2Buffer4
Extra Line
*/
combine(tempBuffer, buff2, 0)
/*output
buff2 = "\n"
combine(tempBuffer, buff2, 0)
----------------------------------------------------------------
Some large Buffer1Buffer3Some large Buffer2Buffer4Extra Line
*/
}
}
DB diffDB = create("diff...", styleCentered)
DBE difftextbox = richText(diffDB, "modifications", "", 850, 400, true)
realize diffDB
useRTFColour(difftextbox, true)
set(difftextbox, tempStringOf tempBuffer)
show diffDB
delete resBuf
delete buff1
delete buff2
delete Buffer1
delete Buffer2
delete tempBuffer
}
parseBufferLine(firstrun, LinesOfBuffer1, LinesCntOfBuffer1)
parseBufferLine(secondrun, LinesOfBuffer2, LinesCntOfBuffer2)
diffx(LinesOfBuffer1, LinesOfBuffer2)
delete LinesOfBuffer1
delete LinesOfBuffer2
delete firstrun
delete secondrun
SystemAdmin - Sat Mar 16 00:45:24 EDT 2013 |
Re: Large buffer and diff limitations |
Re: Large buffer and diff limitations
I'm guessing your "while search" line inadequately handles the case when the input line ends in a EOL. Test this string:
Print the values of "from" and "length(line)" after your loop, then you will know to add somthing like this:
*********************************************** Now onto your problem that does not translate into German... I'm somewhat fuzzy on richText and have adopted a random-modifications approach to debugging; stopping when it looks right. One of those random-modifications that I preserved was to replace all occurances of:
My hackles suggest "\\par" is inadequate since I think.. changing:
So there you are, something to play with. If you figure out something concrete please let us know. -Louie I think perhaps few of my posts transtate into any other language. lol My "random-approach" has resulted in what is by far my worst code; got rich-text processing spread over 4 include files and most of it poorly commented and also most commented out. I cannot follow it. On worse news, I think there is a difference is preparation of rich text strings between [1] sending to an attr value, [2] sending to a dialog box, and [3] sending to MS-Word; although [1] and [2] may be the same. |
Re: Large buffer and diff limitations -Louie |
Re: Large buffer and diff limitations llandale - Sat Mar 16 15:06:09 EDT 2013
Hello, skp += "\n "// Not sure why I need to print the extra space after the '\n'
string diffObject(Object& osrc, Skip& Line)
{
Link l = null
ModName_ otherMod = null
Object othero = null
string temp = null
int absno = osrc."Absolute Number"
Buffer skp = create (); skp = ""
for l in all(osrc->"*") do {
ModuleVersion otherVersion = targetVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) {delete otherVersion; continue}
othero = target l
if (null othero) {load(otherVersion,false)}
othero = target l
if (null othero) {delete otherVersion; continue}
if (isDeleted othero) {delete otherVersion; continue}
if(isDeleted osrc) {
skp += "Softdeleted - "
}
skp += fullName(module(osrc)) "-" probeAttr_(osrc,"Absolute Number") "\t->\t[" fullName(module(l)) "]\t->\t" fullName(otherMod) "-" probeAttr_(othero,"Absolute Number")
//skp += fullName(module(osrc)) "-" probeAttr_(osrc,"Absolute Number") "\t->\t" fullName(otherMod) "-" probeAttr_(othero,"Absolute Number")
if (isBaseline(otherVersion)) {
skp += " [" versionString(otherVersion) "]"
}
skp += "\n "// Not sure why I need to print the extra space after the '\n'
delete otherVersion
}
temp = stringOf(skp)
if(!null temp) {
put(Line, absno, temp)
}
delete skp
return temp
}
Attachments attachment_14958046_transferLinks.dxl |
Re: Large buffer and diff limitations SystemAdmin - Mon Mar 18 10:48:05 EDT 2013
Hello, skp += "\n "// Not sure why I need to print the extra space after the '\n'
string diffObject(Object& osrc, Skip& Line)
{
Link l = null
ModName_ otherMod = null
Object othero = null
string temp = null
int absno = osrc."Absolute Number"
Buffer skp = create (); skp = ""
for l in all(osrc->"*") do {
ModuleVersion otherVersion = targetVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) {delete otherVersion; continue}
othero = target l
if (null othero) {load(otherVersion,false)}
othero = target l
if (null othero) {delete otherVersion; continue}
if (isDeleted othero) {delete otherVersion; continue}
if(isDeleted osrc) {
skp += "Softdeleted - "
}
skp += fullName(module(osrc)) "-" probeAttr_(osrc,"Absolute Number") "\t->\t[" fullName(module(l)) "]\t->\t" fullName(otherMod) "-" probeAttr_(othero,"Absolute Number")
//skp += fullName(module(osrc)) "-" probeAttr_(osrc,"Absolute Number") "\t->\t" fullName(otherMod) "-" probeAttr_(othero,"Absolute Number")
if (isBaseline(otherVersion)) {
skp += " [" versionString(otherVersion) "]"
}
skp += "\n "// Not sure why I need to print the extra space after the '\n'
delete otherVersion
}
temp = stringOf(skp)
if(!null temp) {
put(Line, absno, temp)
}
delete skp
return temp
}
-Louie It really ERKS me seeing variable "skp" represent a Buffer! |
Re: Large buffer and diff limitations Found my issue it was the compare against the temp string. see the below code for my fixed logic. Thank you.
void diffObject(Object& osrc, Skip& Line)
{
Link l = null
ModName_ otherMod = null
Object othero = null
int absno = osrc."Absolute Number"
Buffer buffLine = create (); setempty(buffLine)
for l in all(osrc->"*") do {
ModuleVersion otherVersion = targetVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) {delete otherVersion; continue}
othero = target l
if (null othero) {load(otherVersion,false)}
othero = target l
if (null othero) {delete otherVersion; continue}
if (isDeleted othero) {delete otherVersion; continue}
if(isDeleted osrc) {
buffLine += "Softdeleted - "
}
buffLine += fullName(module(osrc)) "-" probeAttr_(osrc,"Absolute Number") "\t->\t[" fullName(module(l)) "]\t->\t" fullName(otherMod) "-" probeAttr_(othero,"Absolute Number")
//buffLine += fullName(module(osrc)) "-" probeAttr_(osrc,"Absolute Number") "\t->\t" fullName(otherMod) "-" probeAttr_(othero,"Absolute Number")
if (isBaseline(otherVersion)) {
buffLine += " [" versionString(otherVersion) "]"
}
buffLine += "\n"
delete otherVersion
}
if(!null buffLine) {
put(Line, absno, stringOf buffLine)
}
delete buffLine
}
|